/*==============================================================================
**                                  FROGBOOT
**                      Proprietary - Copyright (C) 2014
**------------------------------------------------------------------------------
** Supported MCUs      : MCU STM32
** Supported Compilers : KeilC
**------------------------------------------------------------------------------
** File name         : ComM_Cfg.h
**  
** Module name       : Communication Management
**
** Summary: Header file of communication Management module
**
**= History ===================================================================
** 00.00.01  15/1/2014  Cuong Chu
**           - Creation
** 00.00.01  29/7/2014  Cuong Chu
**           - Added COM4,COM5 IRQ channels
==============================================================================*/
#ifndef __COM_M_CFG_H__
#define __COM_M_CFG_H__
/******************************************************************************/
/* INCLUSIONS                                                                 */
/******************************************************************************/
#include "stdint.h"
#include "Com/Com.h"
/******************************************************************************/
/* DEFINITION OF TYPES                                                        */
/******************************************************************************/
/* ComM Configuration parameters */
typedef struct
{
  DV_COM_NameType     Port;
  DV_COM_BaudrateType Baudrate;
  uint8_t             IntChn;
  DV_COM_IntPrio      Prio;
}ComM_PortConfigType;

/*  IRQ hanlder */
extern void USART1_IRQHandler(void);
extern void USART2_IRQHandler(void);
extern void USART3_IRQHandler(void);
extern void USART4_IRQHandler(void);
extern void USART5_IRQHandler(void);
/*******************************************************************************/
/* DEFINITION OF COMM MSG                                                      */
/*******************************************************************************/
/*
  Message 
   _____________________________________________________________________________________
  | HEADER |  SrcID | DstID  | MsgID |DLC  |         DATA           | Checksum | FOOTER |
  |________|________|________|_______|_____|________________________|__________|________|
   2bytes   4bytes   4bytes   1byte   1byte  8bytes                  1bytes     2bytes
     0 1    2345     6789     10      11    12 13 14 15 16 17 18 19   20         21 22
  Network
  ________
 | Master |  
 |________|
     ||
     ||    RS485Bus
     +========================================= ... =======
                  ||               ||
                  ||               ||
              __________       __________
             |  Slave 1 |     |  Slave 2 |
             |__________|     |__________|
  */
/*******************************************************************************/
/* DEFINITION OF CONSTS                                                        */
/*******************************************************************************/
/* Data length per message in communication */
#define COMM_DATA_LENGTH                    8
/* Message length in communication */
#define COMM_MESSAGE_LENGTH                 23
/* Port Data buffer length */
#define COMM_PORT_DATA_BUFFER_LEN           512
/* Message header */        
#define COMM_MESSAGE_HEADER                 0xA5A5
/* Message footer */
#define COMM_MESSAGE_FOOTER                 0x5A5A
/* Broad cast ID from slave */
#define COMM_MESSAGE_ID_BROADCAST           0xFFFF
/* Number of hardware com */
#define COMM_NBR_COM                        5 
/* Number of message payload */
#define COMM_MAX_PAYLOAD_SIZE               16
/* padding byte */
#define COMM_MESSAGE_PADDING_BYTE           0xAA
/* timer sampling byte */
#define COMM_SAMPLING_TIME                  0
#endif /* __COM_M_CFG_H__ */
